﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
using System.Web.Configuration;
using HospitalSystem.Core;

namespace HospitalSystem
{
    public partial class showcidinfo : System.Web.UI.Page
    {
        private show_Image _showimage;
        protected void Page_Load(object sender, EventArgs e)
        {
            showsession();
            _showimage = new show_Image();
            _showimage.show_Images(cid_label, Image1);
        }

        protected void showsession()
        {
            String ShowValue = (string)Session["CID"];
            cid_label.Text = ShowValue;
            String ShowValue2 = (string)Session["LastName"];
            lname.Text = ShowValue2;

            String ShowValue3 = (string)Session["FirstName"];
            fname.Text = ShowValue3;



        }



        protected void checkcaseno()
        {


            string constr = WebConfigurationManager.ConnectionStrings["strconnection"].ConnectionString;
            SqlConnection scon = new SqlConnection(constr);
            //ต้องการแก้เคสที่มีอยู่แล้ว
            scon.Open();
            SqlCommand cmd = new SqlCommand("SELECT CID from Evaluation where CID = @sj", scon);
            cmd.Parameters.AddWithValue("@sj", cid_label.Text);
            SqlDataReader reader = cmd.ExecuteReader();
            if (reader.Read() != false)
            {
                Response.Redirect("~/Choosing.aspx");
            }

            else
            {

                Response.Redirect("~/cal.aspx");

            }
            reader.Close();

        }








        protected void Button1_Click(object sender, EventArgs e)
        {
            checkcaseno();
         
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            Response.Redirect("~/findchild2.aspx");
        }
    }
}